# -*- coding: utf-8 -*-
# @Time : 2020/10/20 上午10:51
# @Author : cc
# @Description : 功能描述
# @Email : chenchen@starmerx.com
# @Project : djangoProject
from polls.models import Choice, Question
from django.utils import timezone
from django.db import transaction


@transaction.atomic
def insert():
    insert_question()
    insert_choice()


def insert_question():
    print('insert_question')
    question = Question()
    question.question_text = 'question_text'
    question.pub_date = timezone.now()
    question.save()


def insert_choice():
    print('insert_choice')
    raise Exception("11111111")
    choice = Choice()
    choice.question_id = 1
    choice.choice_text = 'choice_text'
    choice.votes = 1
    choice.save()
